var  webpack=require('webpack');
var helper=require("./helper");
var path = require('path');
const svgDirs = [
    require.resolve('antd-mobile').replace(/warn\.js$/, ''),  // 1. 属于 antd-mobile 内置 svg 文件
    helper.root('src/svg')
];
const host="http://192.168.3.69:8080";
//http://192.168.3.69:8080
//http://192.168.199.241:8080
module.exports={
    devtool:"cheap-module-eval-source-map",
    entry:[
        'react-hot-loader/patch',
        'webpack-dev-server/client?'+host,
        'webpack/hot/only-dev-server',
        helper.root('app.js')
    ],
    output:{
        path:helper.root('build'),
        filename:'app.js',
        publicPath:"/build/",
        chunkFilename: '[name].[chunkhash:5].chunk.js',
    },
    module: {
        loaders: [{
            test: /\.(js|jsx|ts)$/,
            loaders: ['babel']
        },{
            test: /\.less$/,
            loader: 'style!css!less'
        },
            {
            test: /\.sass$/,
            loader: 'style!css!sass'
        }, {
                test: /\.css$/,
                loader: 'style!css'
            },
            {
            test: /\.(gif|jpg|png|woff|eot|ttf)\??.*$/,
            loader: 'url-loader?limit=50000&name=[path][name].[ext]'
            },
            {
                test: /\.(svg)$/i,
                loader: 'svg-sprite',
                include: svgDirs,  //
            }
        ]
    },
    plugins: [
        new webpack.DllReferencePlugin({
            context: __dirname,
            manifest:require('./../manifest.json')
        }),
        new webpack.DefinePlugin({
            'process.env': {
                'NODE_ENV': JSON.stringify('development')
            }
        }),
        new webpack.HotModuleReplacementPlugin()
    ],
    resolve: {
        modulesDirectories: ['node_modules', path.join(__dirname, '../node_modules')],
        extensions: ['', '.web.js',  '.js', '.json','.css','.svg','html','.less']
    }
};